package cn.fengshenghospital.controller;

import cn.fengshenghospital.entity.Lead;
import cn.fengshenghospital.service.LeadService;
import cn.fengshenghospital.vo.JsonBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/lead")
public class LeadController {

    @Autowired
    private LeadService leadService;
    @GetMapping("/queryAllLead")
    public JsonBean queryAllLead(){
        JsonBean jsonBean=new JsonBean("queryAllLead");
        try {
            List<Lead> list= leadService.queryAllLead();
            jsonBean.setData(list);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
    @GetMapping("/queryLeadById")
    public JsonBean queryLeadById(int id){
        JsonBean jsonBean=new JsonBean("queryLeadById");
        try {
            Lead lead=leadService.queryLeadById(id);
            jsonBean.setData(lead);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
}
